package redis;

import com.alibaba.fastjson.JSONObject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;

public class TestTX {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.56.100", 6379);
        Transaction multi = jedis.multi();

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("hello","world");
        jsonObject.put("name","yuliuhui");
        String s = jsonObject.toJSONString();
        
        try {
            multi.set("user5", s);
            multi.set("user6", s);
            int i = 1/0;
            multi.exec();
        } catch (Exception e) {
            multi.discard();
            e.printStackTrace();
        } finally {
            System.out.println(jedis.get("user5"));
            System.out.println(jedis.get("user6"));
            jedis.close();
        }
        
    }
}
